package com.hzh.audioflutter.my_audio_recorder_example

import android.Manifest
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import com.hjq.permissions.Permission
import com.hjq.permissions.XXPermissions
import io.flutter.embedding.android.FlutterActivity
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler

class MainActivity: FlutterActivity(){

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        XXPermissions.with(this)
            .permission(Permission.RECORD_AUDIO, Permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.POST_NOTIFICATIONS)
            .request { _, all ->
                if (all) {
                    Toast.makeText(applicationContext, "授权OK！", Toast.LENGTH_SHORT).show()
                } else {
                    Toast.makeText(applicationContext, "请先授权！", Toast.LENGTH_SHORT).show()
                    io.flutter.Log.e("TAG_ME", "startRecord 4")
                }
            }
    }

}
